/* * @Author: hhy * @Date: 2019-02-22 11:01:05 * @Last Modified by: hhy * @Last
Modified time: 2019-05-06 14:04:30 * @文件说明: 表单组件 */
<template>
  <el-form
    ref="hForm"
    :label-width="labelWidth"
    :rules="rules"
    :label-position="labelPosition"
    hide-required-asterisk
    v-bind="$attrs"
    class="h-form"
    @submit.prevent
  >
    <slot />
    <el-form-item v-if="btn">
      <div class="from-bottom">
        <el-button
          @click="$emit('cancel')"
          style="width: 100px"
          class="withdraw abolish"
          >取消</el-button
        >
        <el-button
          style="width: 100px"
          :loading="load"
          type="primary"
          class="withdraw date-button"
          @click="confirm"
          >{{ confirmText }}</el-button
        >
      </div>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  inheritAttrs: false,
  props: {
    refkey: {
      type: String,
      default: "",
    },
    labelPosition: {
      type: String,
      default: "left",
    },
    labelWidth: {
      type: String,
      default: "80px",
    },
    btn: {
      type: Boolean,
      default: true,
    },
    confirmText: {
      type: String,
      default: "确定",
    },
    load: {
      type: Boolean,
      default: false,
    },
    stop: {
      type: Boolean,
      default: false,
    },
    rules: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  methods: {
    confirm() {
      if (this.load === false) this.$emit("confirm");
    },
  },
};
</script>

<style lang="scss">
.h-form {
  width: 100%;
  ::v-deep(.el-form-item) {
    .el-date-editor,
    .el-select,
    .el-upload,
    .el-upload-dragger {
      width: 100%;
    }
  }

  .from-bottom {
    margin: 30px 0 10px 0;
    text-align: center;
    .el-form-item__content {
      margin-left: 0 !important;
      text-align: center;
    }
    .date-button {
      margin-left: 50px;
    }
  }
}
</style>
